{% extends 'cms/cms_base.html' %}

{% block title %}用例分组{% endblock %}

{% block head %}
    <script src="{{ static("cms/js/caseGroupManage.js") }}"></script>
{% endblock %}

{% block page_title %}用例分组（共 {{ total }} 条数据）{% endblock %}

{% block main_content %}
    <div class="top-box-group" style="float: right; padding-bottom: 5px;">
        <button class="btn btn-warning" data-toggle="modal" data-target="#addcasegroup-dialog">添加分组</button>
        <button type="button" class="btn btn-warning" id="refresh-btn" onclick="window.location.reload();">刷新</button>
    </div>
    <table class="table table-bordered">
        <thead>
            <tr>
                <th>分组名称</th>
                <th>分组编码</th>
                <th>状态</th>
                <th>创建人</th>
                <th>更新人</th>
                <th style="width: 160px;">创建时间</th>
                <th style="width: 160px;">更新时间</th>
                <th style="width: 140px;">操作</th>
            </tr>
        </thead>
        <tbody>
            {% for group in groups %}
                <tr data-group_name="{{ group.group_name }}" data-group_code="{{ group.group_code }}" data-id="{{ group.group_id }}">
                    <td>{{ group.group_name }}</td>
                    <td>{{ group.group_code }}</td>
                    {% if group.status == 1 %}
                        <td style="color: green;">启用</td>
                    {% elif group.status == 0 %}
                        <td style="color: red;">禁用</td>
                    {% else %}
                        <td>{{group.status}}</td>
                    {% endif %}
                    <td>{{ group.create_by }}</td>
                    <td>{{ group.update_by }}</td>
                    <td>{{ group.create_at }}</td>
                    <td>{{ group.update_at }}</td>
                    <td>
                        <button class="btn btn-default btn-xs edit-casegroup-btn">编辑</button>
                        {% if group.status == 1 %}
                            <button class="btn btn-warning btn-xs status-casegroup-btn" id="disableBtn" value="0">禁用</button>
                        {% else %}
                            <button class="btn btn-primary btn-xs status-casegroup-btn" id="enableBtn" value="1">启用</button>
                        {% endif %}
                        <button class="btn btn-danger btn-xs delete-casegroup-btn" id="delete-casegroup-btn">删除</button>
                    </td>
                </tr>
            {% endfor %}
        </tbody>
    </table>
    {{ pagination.links }}

    <!-- 新增 -->
    <div class="modal fade" id="addcasegroup-dialog" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                            aria-hidden="true" onclick="location.reload();">&times;</span></button>
                    <h4 class="modal-title" id="myModalLabel">添加/修改用例分组</h4>
                </div>
                <div class="modal-body">
                    <form action="" class="form-horizontal">
                        <div class="form-group">
                            <label class="col-sm-3 control-label"><a>*</a>分组名称：</label>
                            <div class="col-sm-9">
                                <input maxlength="50" type="text" class="form-control" name="groupname" placeholder="用例分组名称，最多50个字符">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label"><a>*</a>分组编码：</label>
                            <div class="col-sm-9">
                                <input maxlength="20" type="text" class="form-control" name="groupcode" placeholder="用例分组编码，最多20个字符">
                            </div>
                        </div>
                        <span style="color: red">说明：分组编码是用来生成分组下的用例编号的，不能修改，只能使用字母、数字、减号、下划线</span>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal" onclick="location.reload();">关闭</button>
                    <button type="button" class="btn btn-primary" id="save-casegroup-btn">保存</button>
                </div>
            </div>
        </div>
    </div>
{% endblock %}